<?php
    
    // SWFAddress code fully compatible with Apache HTTPD
    
    $swfaddress_value = '/';
    $swfaddress_path = '/';
    $swfaddress_parameters = array();
    $swfaddress_content = '';
    
    function is_msie() {
        return strstr(strtoupper($_SERVER['HTTP_USER_AGENT']), 'MSIE');
    }
    
    function swfaddress() {
    
        global $swfaddress_value, $swfaddress_path, $swfaddress_parameters, $swfaddress_content;
        $base = swfaddress_base();
        session_start();

        if ('application/x-swfaddress' == (isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 
            (isset($_SERVER['HTTP_CONTENT_TYPE']) ? $_SERVER['HTTP_CONTENT_TYPE'] : ''))) {
            $swfaddress_value = preg_replace('/&hash=(.*)$/', '#$1', $_SERVER['QUERY_STRING']);
            $_SESSION['swfaddress'] = $swfaddress_value;
            echo('location.replace("' . $base . '/#' . $swfaddress_value . '")');
            exit();
        }
        
        if (isset($_SESSION['swfaddress'])) {
            $swfaddress_value = $_SESSION['swfaddress'];
            unset($_SESSION['swfaddress']);
        } else {
            $page = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1);
            $swfaddress_value = str_replace($base, '', (strpos($page, '.php') && $page != 'index.php') ? $_SERVER['REQUEST_URI'] : str_replace($page, '', $_SERVER['REQUEST_URI']));
        }
        
        $query_string = (strpos($swfaddress_value, '?')) ? substr($swfaddress_value, strpos($swfaddress_value, '?') + 1, strlen($swfaddress_value)) : '';
        
        if ($query_string != '') {
            $swfaddress_path = substr($swfaddress_value, 0, strpos($swfaddress_value, '?'));
            $params = explode('&', str_replace($swfaddress_path . '?', '', $swfaddress_value));
            for ($i = 0; $i < count($params); $i++) {
                $pair = explode('=', $params[$i]);
                $swfaddress_parameters[$pair[0]] = $pair[1];
            }
        } else {
            $swfaddress_path = $swfaddress_value;
        }
        
        $url = strtolower(array_shift(explode('/', $_SERVER['SERVER_PROTOCOL']))) . '://';
        $url .= $_SERVER['SERVER_NAME'];
        $url .= swfaddress_base() . '/datasource.php?swfaddress=' . $swfaddress_path;
        $url .= (strpos($swfaddress_value, '?')) ? '&' . substr($swfaddress_value, strpos($swfaddress_value, '?') + 1, strlen($swfaddress_value)) : '';

        $fh = fopen($url, 'r');
        while (!feof($fh)) {
            $swfaddress_content .= fgets($fh, 4096);
        }    
        fclose($fh);

        if (strstr($swfaddress_content, 'Status(')) {
            $begin = strpos($swfaddress_content, 'Status(', 0);
            $end = strpos($swfaddress_content, ')', $begin);
            $status = substr($swfaddress_content, $begin + 7, $end - $begin - 7);
            if (php_sapi_name() == 'cgi') {
                header('Status: ' . $status);
            } else {
                header('HTTP/1.1 ' . $status);
            }
        }
        
        if (is_msie()) {
        
            $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? 
                preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']) : '';
            
            $file_last_modified = filemtime($_SERVER['SCRIPT_FILENAME']);
            $gmdate_modified = gmdate('D, d M Y H:i:s', $file_last_modified) . ' GMT';
        
            if ($if_modified_since == $gmdate_modified) {
                if (php_sapi_name() == 'cgi') {
                    header('Status: 304 Not Modified');
                } else {
                    header('HTTP/1.1 304 Not Modified');
                }
                exit();
            }
        
            header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT');
            header('Last-Modified: ' . $gmdate_modified);
            header('Cache-control: max-age=' . 86400);
        }
     }

    function swfaddress_base() {
        return substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
    }
         
    function swfaddress_title($title) {
        if (!is_msie()) {
            $names = swfaddress_path_names();
            for ($i = 0; $i < count($names); $i++) {
                $title .= ' / ' . strtoupper(substr($names[$i], 0, 1)) . substr($names[$i], 1);
            }
        }
        echo($title);
    }
    
    function swfaddress_resource($resource) {
        echo(swfaddress_base() . $resource);
    }
    
    function swfaddress_link($link) {
        echo(swfaddress_base() . $link . '" onclick="SWFAddress.setValue(this.rel); this.blur(); return false;"  rel="' . $link);
    }
    
    function swfaddress_social($link) {
        global $swfaddress_value;
        $names = swfaddress_path_names();
        $title = '';
        for ($i = 0; $i < count($names); $i++) {
            $title .= ' / ' . strtoupper(substr($names[$i], 0, 1)) . substr($names[$i], 1);
        }
        $link = str_replace('$url', strtolower(array_shift(explode('/', $_SERVER['SERVER_PROTOCOL']))) . '://' . $_SERVER['SERVER_NAME'] . swfaddress_base() . $swfaddress_value, $link);
        $link = str_replace('$title', $title, $link);
        $link = str_replace(' ', '%20', $link);
        echo($link . '" onclick="SWFAddress.href(this.href); this.blur(); return false;');
    }
    
    function swfaddress_content() {
        global $swfaddress_content;
        echo($swfaddress_content);
    }

    function swfaddress_optimizer($resource) {
        global $swfaddress_value;
        $base = swfaddress_base();
        echo($base . $resource . (strstr($resource, '?') ? '&amp;' : '?') . 'swfaddress=' . urlencode($swfaddress_value) . '&amp;base=' . urlencode($base));        
    }
    
    function swfaddress_path() {
        global $swfaddress_path;
        return $swfaddress_path;
    }
    
    function swfaddress_path_names() {
        global $swfaddress_path;
        $names = explode('/', $swfaddress_path);
        if (substr($swfaddress_path, 0, 1) == '/')
            array_splice($names, 0, 1);
        if (substr($swfaddress_path, count($swfaddress_path) - 1, 1) == '/')
            array_splice($names, count($names) - 1, 1);
        return $names;
    }
    
     swfaddress();
     
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
		<!--					FICHEROS JAVASCRIPT					-->

		<!--	Controller											-->
		<script type="text/javascript" src="javascript/controller/etc.js"></script>
		<script type="text/javascript" src="javascript/controller/events.js"></script>
		<script type="text/javascript" src="javascript/controller/timer.js"></script>
		<script type="text/javascript" src="javascript/controller/webpage.js"></script>

		<!--			Server											-->
		<script type="text/javascript" src="javascript/controller/server/ajax.js"></script>
		<script type="text/javascript" src="javascript/controller/server/json.js"></script>

		<!--			Graphic											-->
		<script type="text/javascript" src="javascript/controller/graphic/fifo.js"></script>
		<script type="text/javascript" src="javascript/controller/graphic/xobject.js"></script>
		<script type="text/javascript" src="javascript/controller/graphic/messagebox.js"></script>

		<!--			Form											-->
		<script type="text/javascript" src="javascript/controller/form/field.js"></script>
		<script type="text/javascript" src="javascript/controller/form/cell.js"></script>
		<script type="text/javascript" src="javascript/controller/form/row.js"></script>
		<script type="text/javascript" src="javascript/controller/form/form.js"></script>

		<!--	Extern													-->
		<script type="text/javascript" src="javascript/extern/jquery-1.3.2.js"></script>
		<script type="text/javascript" src="javascript/extern/func.js"></script>

		<script type="text/javascript" src="javascript/extern/swfaddress/swfaddress.js"></script>


		<!--	WebPages												-->
		<script type="text/javascript" src="javascript/webpages/home.js"></script>
		<script type="text/javascript" src="javascript/webpages/contacto.js"></script>
		<script type="text/javascript" src="javascript/webpages/blog.js"></script>


		<!--	Main													-->
		
		<script type="text/javascript" src="javascript/main.js"></script>
		<script type="text/javascript" src="javascript/portafolio.js"></script>

		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<title>Grado Dos</title>

	<link href="img/favicon.png" rel='shortcut icon' type='image/png'>

	</head>

	<body>
		<div class="header">
			<div id="degradado"> </div>
			<a href="index.html"><img src="img/logov1.png"/></a>
		</div>

		<div id="content">
			<div class="roundbox">

				<div class="main_border bord11"></div>

				<div class="main_border bord01"></div>
				<div class="main_bar bar11"></div>

				<div class="main_bord_cont">
					<div id="menu" class="menu">
					<div id="linker">
						<ul>
							<li><a id="link_home" href="<?php swfaddress_link('/home.html'); ?>">Home</a></li>
							<li><a id="link_portafolio" href="<?php swfaddress_link('/portafolio.html'); ?>">Portafolio</a></li>
							<li><a id="link_contacto" href="<?php swfaddress_link('/contacto.html'); ?>">Contacto</a></li>
							<li><a id="link_blog" href="<?php swfaddress_link('/blog.html'); ?>">Blog</a></li>
						</ul>
					</div>
					</div>
				</div>

				<div class="main_border bord00"></div>
				<div class="main_border bord10"></div>
				<div class="main_bar bar11"></div>

			</div>
			<div class="roundbox">

				<div class="main_border bord11"></div>

				<div class="main_border bord01"></div>
				<div class="main_bar bar11"></div>

				<div class="main_bord_cont">
					<div id="rbcontent" class="main_cont"></div>	
				</div>

				<div class="main_border bord00"></div>
				<div class="main_border bord10"></div>
				<div class="main_bar bar11"></div>

			</div>
		</div>
		<div class="footer">
			<br />
			<p> Designed by Grado Dos </p>
		</div>
	</body>
</html>
